﻿@page
@model IndexModel
@{
ViewData["Title"] = "Home page";
}

<script>
    var exports = { __esModule:true }, module = { exports:exports }
    function require(name) { return exports[name] || window[name] }
</script>
<script src="/js/servicestack-client.js"></script>

<div class="text-center">
    <h1 class="display-4">Welcome</h1>
    <p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>

    <h3>Sign In using credentials</h3>

    <form action="/auth/credentials" method="post">
        <div class="form-row">
            <div class="form-group" data-validation-summary="userName,password"></div>
        </div>
        <div class="form-row">
            <div class="form-group">
                <input class="form-control form-control-lg" name="userName" type="text" placeholder="UserName">
            </div>
        </div>
        <div class="form-row">
            <div class="form-group">
                <input class="form-control form-control-lg" name="password" type="password" placeholder="Password">
            </div>
            <div class="form-group col-md-4">
                <button type="submit" class="btn btn-lg btn-primary">Login</button>
            </div>
        </div>
        <div class="form-row">
            <div class="form-group">
                <input type="checkbox" id="rememberMe" name="rememberMe" value="true">
                <label for="rememberMe">Remember Me</label>
            </div>
        </div>
        <div class="form-row">
            <div class="form-group col-md-4">
                <a class="lnk" href="/client-ts/register">Register New User</a>
            </div>
        </div>
    </form>

    <div>
        <b>Quick Login:</b>
        <div class="quicklist">
            <span data-click="switchUser:admin@email.com">admin@email.com</span>
            <span data-click="switchUser:new@user.com">new@user.com</span>
            <span data-click="switchUser:as@if.com">as@if.com</span>
        </div>
    </div>
</div>

<script>
    Object.assign(window, exports); //import

    bootstrapForm(document.querySelector('form'), {
        success: (r) => {
            location.href = '/';
        }
    });

    bindHandlers({
        switchUser: (u) => {
            (document.querySelector("[name=userName]")).value = u;
            (document.querySelector("[name=password]")).value = 'testTest1!';
        }
    });
</script>
